package demo6;

import java.util.Date;

public class News {
    private int newsId;
    private String newsName;
    private Category category;
    private String newsContent;
    private String newsCreator;
    private Date newsPublishTime;

    public News(int newsId, String newsName, Category category, String newsContent, String newsCreator, Date newsPublishTime) {
        this.newsId = newsId;
        this.newsName = newsName;
        this.category = category;
        this.newsContent = newsContent;
        this.newsCreator = newsCreator;
        this.newsPublishTime = newsPublishTime;
    }

    // 新闻添加
    public static News addNews(int newsId, String newsName, Category category, String newsContent, String newsCreator, Date newsPublishTime) {
        return new News(newsId, newsName, category, newsContent, newsCreator, newsPublishTime);
    }

    // 新闻修改
    public void modifyNews(String newsName, Category category, String newsContent, String newsCreator, Date newsPublishTime) {
        this.newsName = newsName;
        this.category = category;
        this.newsContent = newsContent;
        this.newsCreator = newsCreator;
        this.newsPublishTime = newsPublishTime;
    }

    // 查询信息
    public void queryNews() {
        System.out.println("新闻编号: " + newsId);
        System.out.println("新闻名称: " + newsName);
        System.out.println("分类: " + category);
        System.out.println("新闻内容: " + newsContent);
        System.out.println("新闻创建人: " + newsCreator);
        System.out.println("新闻发布时间: " + newsPublishTime);
    }

    // 新闻发布
    public void publishNews() {
        this.newsPublishTime = new Date();
        System.out.println("新闻已发布");
    }
}